// Lang_25 ['break' keyword].nova // The application class. class BreakKeywordApp { // Application class's "main" function. public static void main( String[] args ) { ////////////////////////////////////////////////////// // Demonstrate the 'break' keyword in a 'for' loop. // ////////////////////////////////////////////////////// int i; for ( i = 0; true; i++ ) { if ( i >= 10 ) { break; } Stream.writeLine( "i = " + Integer.toString( i ) ); } // Output the final values of i. Stream.writeLine( "final value of i = " + Integer.toString( i ) ); //////////////////////////////////////////////////////////////////////// // Demonstrate nested 'break' keywords in 'while' & 'do-while' loops. // //////////////////////////////////////////////////////////////////////// int a, b, c = 0; while ( true ) { b = 0; do { a = 0; while ( true ) { // Should be output 1 * 2 * 3 times. Stream.write( '#' ); if ( ++a == 1 ) { break; } } if ( ++b == 2 ) { break; } } while ( true ); if ( ++c == 3 ) { break; } } // New line character. Stream.writeLine( "" ); // Output the final values of a, b and c. Stream.writeLine( "final value of a = " + Integer.toString( a ) ); Stream.writeLine( "final value of b = " + Integer.toString( b ) ); Stream.writeLine( "final value of c = " + Integer.toString( c ) ); } }